//
//  ZCommontHeader.h
//  danpin
//
//  Created by chuangjia on 31/8/15.
//  Copyright (c) 2015 chuangjia. All rights reserved.
//

#import <UIKit/UIKit.h>

#ifndef iphone6_Fix_Demo_GTCommontHeader_h
#define iphone6_Fix_Demo_GTCommontHeader_h


CG_INLINE CGRect CGRectMakeAuto(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGFloat autoSizeScaleX =1.0;
    CGFloat autoSizeScaleY =1.0;
    if([[UIScreen mainScreen] bounds].size.height > 480){
        if([[UIScreen mainScreen] bounds].size.height > 568)
        {
            if ([[UIScreen mainScreen] bounds].size.height > 667) {
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/414;
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/736;
            }else{
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/375;
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/667;
            }
        }else
        {
            autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/320;
            autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/568;
        }
    }else{
        autoSizeScaleX = 1.0;
        autoSizeScaleY = 1.0;
    }
    
    CGRect rect;
    rect.origin.x = x * autoSizeScaleX;
    rect.origin.y = y * autoSizeScaleY;
    rect.size.width = width * autoSizeScaleX;
    rect.size.height = height *autoSizeScaleY;
    return rect;
}
CG_INLINE CGFloat XAuto(CGFloat x)
{
    CGFloat autoSizeScaleX =1.0;
    if([[UIScreen mainScreen] bounds].size.height > 480){
        if([[UIScreen mainScreen] bounds].size.height > 568)
        {
            if ([[UIScreen mainScreen] bounds].size.height > 667) {
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/414;
            }else{
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/375;
            }
        }else
        {
            
            autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/320;
        }
    }else{
        autoSizeScaleX = 1.0;
    }
    return x * autoSizeScaleX;
}
CG_INLINE CGFloat YAuto(CGFloat y)
{
    CGFloat autoSizeScaleY =1.0;
    if([[UIScreen mainScreen] bounds].size.height > 480){
        if([[UIScreen mainScreen] bounds].size.height > 568)
        {
            if ([[UIScreen mainScreen] bounds].size.height > 667) {
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/736;
            }else{
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/667;
            }
        }else
        {
            autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/568;
        }
    }else{
        autoSizeScaleY = 1.0;
    }
    return y * autoSizeScaleY;
}
CG_INLINE CGFloat widthAuto(CGFloat width)
{
    CGFloat autoSizeScaleX =1.0;
    if([[UIScreen mainScreen] bounds].size.height > 480){
        if([[UIScreen mainScreen] bounds].size.height > 568)
        {
            if ([[UIScreen mainScreen] bounds].size.height > 667) {
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/414;
            }else{
                autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/375;
            }
        }else
        {
            
            autoSizeScaleX = [[UIScreen mainScreen] bounds].size.width/320;
        }
        
    }else{
        autoSizeScaleX = 1.0;
    }
    return width * autoSizeScaleX;
}
CG_INLINE CGFloat hightAuto(CGFloat height)
{
    CGFloat autoSizeScaleY =1.0;
    if([[UIScreen mainScreen] bounds].size.height > 480){
        if([[UIScreen mainScreen] bounds].size.height > 568)
        {
            if ([[UIScreen mainScreen] bounds].size.height > 667) {
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/736;
            }else{
                autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/667;
            }
        }else
        {
            autoSizeScaleY = [[UIScreen mainScreen] bounds].size.height/568;
        }
     
    }else{
        autoSizeScaleY = 1.0;
    }
    return height * autoSizeScaleY;
}
#endif
